package com.aier.school.common;


import java.util.List;

import com.aier.common.common.Constant;
import com.aier.school.entity.SchoolGradeAttendance;


public class SchoolUtil {

    public static String dataShowNum(int num){
        String returnStr ;
        switch(num){
            case 1: 
                returnStr = "星期日";break;
            case 2: 
                returnStr = "星期一";break;
            case Constant.num_3: 
                returnStr = "星期二";break;
            case Constant.num_4: 
                returnStr = "星期三";break;
            case Constant.num_5: 
                returnStr = "星期四";break;
            case Constant.num_6: 
                returnStr = "星期五";break;
            case Constant.num_7: 
                returnStr = "星期六";break;
            default:
                returnStr = "星期一";
        }
        return returnStr;
    }
    
    public static String dateShow(List<Integer> tmplist){
        String str = null;
        if(tmplist.size()==1){
            str = dataShowNum(tmplist.get(0));
        }else{
            str = dataShowNum(tmplist.get(0));
            for(int i=1;i<tmplist.size();i++){
                int tmpnum1 = tmplist.get(i-1);
                int tmpnum2 = tmplist.get(i);
//                System.out.println("tmpnum1:"+tmpnum1+" tmpnum2:"+tmpnum2);
                String tmpstr1 = dataShowNum(tmpnum1);
                String tmpstr2 = dataShowNum(tmpnum2);
                if(tmpnum2==tmpnum1+1){
                    if(i==tmplist.size()-1){
                        str = str + " 至 " + tmpstr2;
                    }else{
                        continue;
                    }
                    
                }else{
                    if (str.split(",")[str.split(",").length-1].trim().equals(tmpstr1)) {
                        str = str +  " , " + tmpstr2;
                    } else {
                        str = str + " 至 " + tmpstr1 + " , " + tmpstr2;
                    }
                    
                }
            }
        }
        
        return str;
    }
    
    public static String showTimeStr(SchoolGradeAttendance sga){
        String str = "";
        if(sga.getSadate()!=null){
            str = str + sga.getSadate().toString();
        }
        if(sga.getEadate()!=null&&sga.getSpdate()!=null){
            str = str + " - " + sga.getEadate().toString() + " " + sga.getSpdate().toString();
        }
        if(sga.getEpdate()!=null){
            str = str + " - " + sga.getEpdate().toString();
        }
        return str;
    }
    

    
}
